export default {
    namespaced: true,
    state: {
        userName: "",
        mobile: "",
        cardCode: "", // 卡号
        isCheck: null, // 是否认证
		userId:'',//
		isManager:"",
    },
    getters: {

    },
    mutations: {
        setUserInfo(state, payload) { // 存取用户信息
            for (let i in payload) {
                for (let j in state) {
                    if (i === j) {
                        state[i] = payload[j]
                    }
                }
            }
        },
    },
    actions: {
        // 登录
        async login({
            state,
            commit,
            dispatch,
            rootState
        }, data) {
            commit('setUserInfo', data);
            uni.setStorageSync('userinfo', JSON.stringify(data));
        },
        // 退出登录
        async logout({
            state,
            rootState
        }) {
            for (let i in state) {
                if (i == 'login_popover' || i == 'keep_login') {
                    state[i] = false
                } else {
                    state[i] = ''
                }
            }
           uni.removeStorageSync('skey');
           uni.removeStorageSync('userinfo');
        }
    },

}
